package com.flejay.dreamrecruiter.tools;

import java.util.List;

/**
 * 
 * @author Victor Fleurant
 *
 */
public final class CustomStringUtils {

	private CustomStringUtils(){
		super();
	}
	
	/**
	 * remove white spaces and extension from content
	 * 
	 * @param content 
	 * 	- ne doit pas contenir de "." en dehors de l'extension
	 * 	- contient au moins un caractere avant et apres le .
	 * ex : "a.c","myFile.xml","myDoc.doc",..
	 * 
	 * @return
	 */
	public final static String removeWhiteSpaceAndExtension(final String content){
		String withoutExtensionAndWhiteSpace = content.replaceAll("\\s", "");
		return withoutExtensionAndWhiteSpace.replaceAll("(\\w+)(\\.)(\\w+)", "$1");
	}
	
	/**
	 * Convert a list of string into a string buffer
	 * 
	 * @param content
	 * @return
	 */
	public final static StringBuffer convert(List<String> content){
		StringBuffer buf = new StringBuffer();
		if (content != null){
			for (String c : content){
				buf.append(c).append(IConstantsUtil.LINE_SEPARATOR);
			}
		}
		return buf;
	}
	
	/**
	 * remove back line from string
	 * 
	 * @param content
	 * @return
	 */
	public final static String removeBackLine(final String content){
		return content.replaceAll("\\r", "");
	}
	
}
